#include <iostream>
#include <fstream>
#include <SFML/Graphics.hpp>
#include <tinyxml.h>
#include "include/screens.hpp"
#include "include/Engine.hpp"

#include <lua.hpp>

using namespace std;

// Fonction principale
int main()
{
    Configs GC;

    // Chargement des paramètres de la fenêtre
    int &screen_width = GC.GetGame()->screen_width;
    int &screen_height = GC.GetGame()->screen_height;
    int &screen_colors = GC.GetGame()->screen_colors;
    int &frame_rate = GC.GetGame()->frame_rate;
    int &resizable = GC.GetGame()->resizable;
    int &closing = GC.GetGame()->closing;
    int styles_parametres = 0; // Paramètre de Style de la fenêtre(redimensionnable, etc...)

    // On applique le style de la fenêtre
    if(resizable == 1)
        styles_parametres = sf::Style::Resize;
    if(closing == 1)
        styles_parametres += sf::Style::Close;

    // Création de la fenêtre de rendu
    sf::RenderWindow App(sf::VideoMode(screen_width, screen_height, screen_colors), "Zeforiu", styles_parametres);
    App.SetFramerateLimit(frame_rate);
    App.ShowMouseCursor(false);

    Engine GameEngine(App);
    GraphicEngine GE(App);
    GameEngine.SetGraphicEngine(&GE);
    GameEngine.SetConfigsEngine(&GC);

    std::vector<Screen*> screens;
    int screen = 0;

    EcranTitre s0;
    screens.push_back (&s0);

    while (screen >= 0)
    {
        screen = screens[screen]->Run(GameEngine);
    }

    return EXIT_SUCCESS;
}
